IsSelfGui(hwnd) {
  selfTitles := ['BaseGUI', 'FullGUI', 'ClipGUI', 'ToolGUI ']
  title := WinGetTitle('ahk_id' hwnd)
  return selfTitles.findIndex(v => Meta.name v = title)
}

GetWindowRectWithoutShadow(hwnd, &x, &y, &w, &h) {
  rect := Buffer(16)
  DllCall('dwmapi\DwmGetWindowAttribute'
    , 'ptr', hwnd, 'uint', 0x9
    , 'ptr', rect, 'int', rect.Size)
  x := NumGet(rect, 'int'), y := NumGet(rect, 4, 'int')
  w := NumGet(rect, 8, 'int') - x, h := NumGet(rect, 12, 'int') - y
}